package com.groot.medical.service;

import java.util.Date;
import java.util.List;

import com.groot.medical.dao.ChronicPatternDAO;
import com.groot.medical.dao.ChronicPatternDAOImpl;
import com.groot.medical.entity.ChronicPattern;
import com.groot.medical.entity.PageBean;
import com.groot.medical.entity.PersonalFiles;

public class ChronicPatternServiceImpl implements ChronicPatternService {
	
	private ChronicPatternDAO chronicPatternDAO = new ChronicPatternDAOImpl();

	@Override
	public PageBean findChronicPatternInfoByPage(int pageNum, int pageSize) {
		int totalRecord = chronicPatternDAO.getAllChronicPatternInfoCounts();
		PageBean pageBean = new PageBean<>(pageNum, pageSize, totalRecord);
		int startIndex = pageBean.getStartIndex();
		pageBean.setList(chronicPatternDAO.findChronicPatternInfoByPage(startIndex,pageSize));
		return pageBean;
	}

	@Override
	public List<PersonalFiles> findAlreadyPayPerson(String personName) {
		//int totalRecord = chronicPatternDAO.getAlreadyPayPerson(personName);
		
		List<PersonalFiles> persons=chronicPatternDAO.findAlreadyPayPerson(personName);
		return persons;
	}

	@Override
	public void AddChronicPatternInfo(ChronicPattern pattern) {
		chronicPatternDAO.AddChronicPatternInfo(pattern);
		
	}

	@Override
	public boolean checkPatternIsExistByIdCardNum(String idcardNumber) {
		boolean flag = chronicPatternDAO.checkPatternIsExistByIdCardNum(idcardNumber);
		return flag;
	}

	@Override
	public boolean checkChronicNameIsEquals(String idcardNumber, String illName) {
		boolean flag = chronicPatternDAO.checkChronicNameIsEquals(idcardNumber,illName);
		return flag;
	}

	@Override
	public boolean checkDateIsOut(String idcardNumber, String date) {
		boolean flag = chronicPatternDAO.checkDateIsOut(idcardNumber,date);
		return flag;
	}
	
	@Override
	public ChronicPattern findChronicInfoByIdCardNum(String idCardNum) {
		ChronicPattern pattern = chronicPatternDAO.findChronicInfoByIdCardNum(idCardNum);
		return pattern;
	}

	@Override
	public int checkIsMakePayInfo(String currentYear,String id) {
		
		return chronicPatternDAO.checkIsMakePayInfo(currentYear,id);
	}

	@Override
	public ChronicPattern findChronicInfoByChronicCode(String id) {
		ChronicPattern pattern = chronicPatternDAO.findChronicInfoByChronicCode(id);
		return pattern;
	}

	@Override
	public void deletePattern(String id) {
		chronicPatternDAO.deletePattern(id);
		
	}
}
